﻿using UnityEngine;
using System.Collections;

public class ColorScript : MonoBehaviour {

	public string ColorCodeHex;
	public Renderer Cube1;
	public Renderer Cube2;
	public Renderer Cube3;
	public Renderer Cube4;

	Color HexToRGB(string Hex)
	{
		byte r = byte.Parse (Hex.Substring (0, 2), System.Globalization.NumberStyles.HexNumber);
		byte g = byte.Parse (Hex.Substring (2, 2), System.Globalization.NumberStyles.HexNumber);
		byte b = byte.Parse (Hex.Substring (4, 2), System.Globalization.NumberStyles.HexNumber);
		return new Color32 (r, g, b, 255);
	}

	// Use this for initialization
	void Start () {
		Cube1.material.color = (HexToRGB (ColorCodeHex));
		if(Cube2) Cube2.material.color = (HexToRGB (ColorCodeHex));
		if(Cube3) Cube3.material.color = (HexToRGB (ColorCodeHex));
		if(Cube4) Cube4.material.color = (HexToRGB (ColorCodeHex));
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
